package com.qww;

import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;

public class Exec10 {

    public static void main(String[] args) {
        Set<Object> set = new HashSet<>();
        for (int i = 1001; i < 10000; i++) {
            int a = i / 1000;
            int b = i % 1000 / 100;
            int c = i % 100 / 10;
            int d = i % 10;
            if (c == 0 && d == 0) continue;
            if (i == 6880)
                System.out.println();

            if (i == (a * 10 + b) * (c * 10 + d) && c != 0) set.add(i);
            if (i == (a * 10 + b) * (d * 10 + c) && d != 0) set.add(i);
            if (i == (a * 10 + c) * (b * 10 + d) && b != 0) set.add(i);
            if (i == (a * 10 + c) * (d * 10 + b) && d != 0) set.add(i);
            if (i == (a * 10 + d) * (b * 10 + c) && b != 0) set.add(i);
            if (i == (a * 10 + d) * (c * 10 + b) && c != 0) set.add(i);

            if (b != 0) {
                if (i == (b * 10 + a) * (c * 10 + d) && c != 0) set.add(i);
                if (i == (b * 10 + a) * (d * 10 + c) && d != 0) set.add(i);
                if (i == (b * 10 + c) * (d * 10 + a) && d != 0) set.add(i);
                if (i == (b * 10 + d) * (c * 10 + a) && c != 0) set.add(i);
            }

            if (c != 0) {
                if (i == (c * 10 + a) * (b * 10 + d) && b != 0) set.add(i);
                if (i == (c * 10 + a) * (d * 10 + b) && d != 0) set.add(i);
                if (i == (c * 10 + d) * (b * 10 + a) && b != 0) set.add(i);
            }

            if (d != 0) {
                if (i == (d * 10 + b) * (c * 10 + a) && c != 0) set.add(i);
                if (i == (d * 10 + c) * (b * 10 + a) && b != 0) set.add(i);
                if (i == (d * 10 + a) * (b * 10 + c) && b != 0) set.add(i);
                if (i == (d * 10 + a) * (c * 10 + b) && c != 0) set.add(i);
            }

        }

        Object[] arr = set.toArray();
        Arrays.sort(arr);
        for (Object i : arr) {
            System.out.println(i);
        }
    }
}
